﻿{include title="菜单管理" keywords="" description=""  file='../application/admin/view/layout/header.html' /}
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 管理员管理 <span class="c-gray en">&gt;</span> 菜单管理 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l"><a href="javascript:;" onclick="admin_permission_add('添加菜单节点','{:url(\'/admin/admin_menu/menuAdd\')}','','600')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加菜单节点</a></span></div>
	<table class="table table-border table-bordered table-bg">
		<thead>
		<tr>
			<th scope="col" colspan="9">菜单节点</th>
		</tr>
		<tr class="text-c">
			<th width="25"><input type="checkbox" class="all-select"></th>
			<th width="25">排序</th>
			<th width="40">ID</th>
			<th width="100">菜单图标</th>
			<th width="200">菜单名称</th>
			<th width="200">URL路径</th>
			<th width="200">是否显示</th>
			<th width="200">菜单状态</th>
			<th width="100">操作</th>
		</tr>
		</thead>
		<tbody class="data1">
		<form action="" class="form">
		{foreach $data as $k => $v}
		<tr class="text-c">
			<td><input type="checkbox" class="select-id"></td>
			<td><input class="input-text text-c" name="{$v['id']}" value="{$v['order']}" style="width:60px;" type="text"></td>
			<td>{$v['id']}</td>
			<td><i class="Hui-iconfont {$v['logo']}"></i></td>
			<td style="text-align: left;">{:str_repeat('　　',$v['level']).'|--'.$v['name']}</td>
			<td>{$v['url']}</td>
			<td>
				{if ($v['type']==0)}
				<span class="label label-default radius">否</span>
				{else}
				<span class="label label-success radius">是</span>
				{/if}
			</td>
			<td>
				{if ($v['status']==0)}
				<span class="label label-default radius">禁用</span>
				{else}
				<span class="label label-success radius">正常</span>
				{/if}
			</td>
			<td>
				<a title="添加" href="javascript:;" onclick="admin_permission_add('添加菜单节点','{:url(\'/admin/admin_menu/menuAdd\',[\'menu_id\'=>$v[\'id\']])}','','600')" class="ml-5" style="text-decoration:none">
					<i class="Hui-iconfont">&#xe600;</i>
				</a>
				<a title="编辑" href="javascript:;" onclick="admin_permission_edit('菜单编辑','{:url(\'admin/admin_menu/menuedit\',[\'id\'=>$v[\'id\']])}','','600')" class="ml-5" style="text-decoration:none">
					<i class="Hui-iconfont">&#xe6df;</i>
				</a>
				<a title="删除" href="javascript:;" onclick="admin_permission_del(this,'{$v[\'id\']}')" class="ml-5" style="text-decoration:none">
					<i class="Hui-iconfont">&#xe6e2;</i>
				</a>
			</td>
		</tr>
		{/foreach}
		</form>
		</tbody>
	</table>
	<div class="cl pd-5 mt-20">
		<label class="btn btn-default size-S radius all-select1">全选</label>
		<input class="btn btn-default size-S radius ml-5 set_sort" type="button" value="批量排序">
	</div>
</div>
<script>
	//选择后背景颜色
	$(".data1 tr").on('mouseover',function () {
		$(this).find('td').css('background-color','#e9e9e9');
    });
    $(".data1 tr").on('mouseout',function () {
        $(this).find('td').css('background-color','');
    });
    //全选按钮
	$(".all-select1").on('click',function () {
        $(".select-id").prop('checked',true);
        $(".all-select").prop('checked',true);
    });
	//排序
	$(".set_sort").on('click',function () {
	    console.log($(".form").serialize());
        $.post('<?php echo url("admin/admin_menu/menuOrder"); ?>',{order_str:$(".form").serialize()},function (msg) {
			if (msg.status =='y'){
                layer.msg(msg.info,{icon:1,time:1000});
                setTimeout(function () {
					location.reload();
                },1000)
			}else{
                layer.msg(msg.info,{icon:1,time:1000});
			}
        });
    })
</script>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">

    /*管理员-菜单-添加*/
    function admin_permission_add(title,url,w,h){
        layer_show(title,url,w,h);
    }
    /*管理员-菜单-编辑*/
    function admin_permission_edit(title,url,w,h){
        layer_show(title,url,w,h);
    }

    /*管理员-菜单-删除*/
    function admin_permission_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            $.ajax({
                type: 'POST',
                url: '<?php echo url("admin/admin_menu/menuDel"); ?>'+'?id='+id,
                dataType: 'json',
                success: function(data){
                    if (data.status=='y'){
                        $(obj).parents("tr").remove();
                        layer.msg(data.info,{icon:1,time:1000});
					}else{
                        layer.msg(data.info,{icon:2,time:1000});
					}

                }
            });
        });
    }
</script>
</body>
</html>